<?php 

/**
* 验证码类
*/
class Code
{
	public $canvas;             //画布对象
	public $canvasWidth=600;    //画布宽度
	public $canvasHeight=200;   //画布高度
	public $codeNum=4;			//验证码个数
	public $lineNum=10;         //干扰线数量
	public $dotNum=20;			//干扰点数量
	public $font;				//字体
	public $str='1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCBNM'; //验证码随机数生成域
	public $res;

	function __construct()
	{
		$this->$canvasWidth=$with;						//画布宽度
		$this->$canvasHeight=$height;					//画布高度
		$this->$codeNum=$randNum;						//验证码个数
		$this->$lineNum=$linenum;						//干扰线数量
		$this->$dotNum=$dotnum;							//干扰点数量
		$this->$font='./funkmachine.ttf';				//字体
		$this->$res=imagecreatetruecolor(600, 200);
	}

	public function show(){
		header('Content-type: image/png');
		for ($i=0; $i < 4; $i++) { 
			$with=((600/4)-100)+$i*((600/4));
			$height=(200+100)/2;
			$color=imagecolorallocate($this->$res, mt_rand(0,254), mt_rand(0,254), mt_rand(0,254));
			imagettftext($this->$res, 100, mt_rand(-10,10), $with, $height, $color, './funkmachine.ttf', $str[mt_rand(0,61)]);
		}
	}



}


 ?>